/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package koor.entity;

import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.*;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "roles")
public class Role extends AbstractEntity{
    
    @Column(name = "title")
    private String title;
    
    @ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
    @JoinTable(name = "role_action", joinColumns = { @JoinColumn(name = "role_id") }, 
            inverseJoinColumns = { @JoinColumn(name = "action_id") })
    private Set<Action> actions = new LinkedHashSet<Action>();
    
    public Role() {
    }

    public Role(String title) {
        this.title = title;
    }

    public Role(String title, int id) {
        super(id);
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Set<Action> getActions() {
        return actions;
    }

    public void setActions(Set<Action> actions) {
        this.actions = actions;
    }
    
}
